<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="controller.DBmanager, java.util.ArrayList, model.SignDao, model.AuctionDAO, model.AuctionBean, model.BidDAO, model.BidBean, java.io.File, java.awt.image.BufferedImage, javax.imageio.ImageIO;"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<% 
	response.setHeader("Cache-Control","no-cache"); //http 1.0
	response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");//http 1.1
	response.setHeader("Pragma","no-cache"); 
	response.setHeader("Expires", "01 Apr 1995 01:10:10 GMT"); 
	DBmanager man = DBmanager.getInstance(getServletContext());
	AuctionBean bean = new AuctionDAO().getAuction(new Integer(request.getParameter("id")));
%>
<table class="main" style="width: 100%;">
	<tr>
		<td class="main" colspan="2"><h1><%= bean.getName() %></h1></td>
	</tr>
	<tr>
		<%
			String imgpath = getServletContext().getRealPath("img");
			File ifile = new File(imgpath + File.separatorChar + bean.getPic());
			BufferedImage i = ImageIO.read(ifile);
			int trueWidth = i.getWidth();
			int printWidth = trueWidth;
			if(printWidth > 1260){ printWidth = 1260; }
			
		%>
		<td class="main" colspan="2">
			<% if(trueWidth > 1760){ out.println("<a href=\"img\\" + ifile.getName() + "\" target=\"_blank\">"); } %>
			<img style="width: <%=printWidth%>px;" src="img/<%= bean.getPic() %>">
			<% if(trueWidth > 1760){ out.println("</a>"); } %>
		</td>
	</tr>
	<tr>
		<td class="main"><strong>Auction made by: </strong><i><%= new SignDao().getUsername(bean.getOwner()) %></i></td>
	</tr>
	<tr>
		<td class="main"><%= bean.getDetails() %></td>
		<td class="main">
			<div id="prizes">
				<jsp:include page="bids.jsp?ID=<%=bean.getID() %>" />
			</div>			
		</td>
	</tr>
	<tr>
		<td class="main"><strong>Time left on auction: </strong><i id=<%= "viewtimer" %>></i></td>
	</tr>
	
</table>
<script type="text/javascript"> initTimer('viewtimer', "<%= bean.getEnd() %>"); </script>